home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-11-18 | 33.8 KB | 1,050 lines | [TEXT/MPS ] |
- C.S.M.P. Digest Wed, 04 Nov 92 Volume 1 : Issue 208
-
- Today's Topics:
-
- DogCow Calls
- DYLAN
- Animated Cursors...
- Q: Stack munging in VBL tasks?
- WDEF's and QuickDraw globals
- How do I draw icl8's?
- JPartialResources.{c,h}
-
-
-
- The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
-
- The digest is a collection of article threads from the internet newsgroup
- comp.sys.mac.programmer. It is designed for people who read c.s.m.p. semi-
- regularly and want an archive of the discussions. If you don't know what a
- newsgroup is, you probably don't have access to it. Ask your systems
- administrator(s) for details. (This means you can't post questions to the
- digest.)
-
- Each issue of the digest contains one or more sets of articles (called
- threads), with each set corresponding to a 'discussion' of a particular
- subject. The articles are not edited; all articles included in this digest
- are in their original posted form (as received by our news server at
- cs.uoregon.edu). Article threads are not added to the digest until the last
- article added to the thread is at least one month old (this is to ensure that
- the thread is dead before adding it to the digest). Article threads that
- consist of only one message are generally not included in the digest.
-
- The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
- [128.223.8.8] in the directory /pub/mac/csmp-digest. Be sure to read the
- file /pub/mac/csmp-digest/README before downloading any files. The most
- recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
- directory /info-mac/digest/csmp. If you don't have ftp capability, the sumex
- archive has a mail server; send a message with the text '$MACarch help' (no
- quotes) to LISTSERV@ricevm1.rice.edu for more information.
-
- The digest is also available via email. Just send a note saying that you
- want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
- automatically receive each new issue as it is created. Sorry, back issues
- are not available through the mailing list.
-
- Send administrative mail to mkelly@cs.uoregon.edu.
-
-
- -------------------------------------------------------
-
- From: stud08@cc4.kuleuven.ac.be (Karl Pottie)
- Subject: DogCow Calls
- Date: 29 Sep 92 14:14:57 GMT
- Organization: K.U.Leuven - Academic Computing Center
-
-
- Moof !
-
- As a true dogcow fan , I'd like to know what the toolbox calls
- enable/disableDogCow() do? On which systems are they available ?
-
- Karl
-
- +++++++++++++++++++++++++++
-
- From: hammett@sbsu1.aukuni.ac.nz (Tim Hammett)
- Date: 29 Sep 92 22:03:35 GMT
- Organization: University of Auckland, New Zealand.
-
- stud08@cc4.kuleuven.ac.be (Karl Pottie) writes:
- >As a true dogcow fan , I'd like to know what the toolbox calls
- >enable/disableDogCow() do? On which systems are they available ?
-
- I think you'll find they're just aliases to the _Unimplemented trap,
- so they'll do whatever that trap does(probably nothing interesting).
- >From the MPW Traps.h file:
-
- #define _Unimplemented 0xA89F
- #define _InitDogCow 0xA89F
- #define _EnableDogCow 0xA89F
- #define _DisableDogCow 0xA89F
- #define _Moof 0xA89F
-
- (Incidentally, I couldn't find any of the DogCow traps in any of the
- AIncludes files, a serious omission IMHO :-))
-
- - --
- Tim Hammett, Botany Dept, Auckland University, New Zealand.
- t.hammett@aukuni.ac.nz Phone: +64-9-373-7599 x8365 FAX: +64-9-373-7416
-
- ---------------------------
-
- From: freeze@ee.byu.edu (Jim Freeze)
- Subject: DYLAN
- Date: 17 Sep 92 15:41:07 GMT
- Organization: Brigham Young University, Provo UT USA
-
-
-
- Has anyone heard of Apple's new OO language, DYLAN?
-
- It stands for DYnamic LANguage.
-
- If you have heard of it, I am trying to find out if is
- is available (i.e. can I get a compiler for it).
- and how much and where?
-
- Thanks for any info
-
- Jim
-
- +++++++++++++++++++++++++++
-
- From: squeegee@world.std.com (Stephen C. Gilardi)
- Date: 17 Sep 92 23:07:44 GMT
- Organization: SQ Software via The World Public Access UNIX, Brookline, MA
-
- freeze@ee.byu.edu (Jim Freeze) writes:
-
- >Has anyone heard of Apple's new OO language, DYLAN?
-
- >It stands for DYnamic LANguage.
-
- >If you have heard of it, I am trying to find out if is
- >is available (i.e. can I get a compiler for it).
- >and how much and where?
-
- >Thanks for any info
-
- >Jim
-
- There's some discussion of it over in comp.lang.scheme from time to time.
- The only publicly available implementation of a Dylan-ish language that
- I know of is called Thomas. It is written in Scheme and is available by
- anonymous ftp from either "crl.dec.com" or "ftp.crl.dec.com" (I don't
- remember which). The following is from the README:
-
- Comments, questions, suggestions, help, etc. should be directed to:
- info-thomas@crl.dec.com
- Requests to be added to this mailing list should be sent to:
- info-thomas-request@crl.dec.com
-
- It runs under Gambit Scheme for example on the Mac.
-
- Good Luck!
-
- - --Steve
- squeegee@world.std.com
-
- +++++++++++++++++++++++++++
-
- From: ksand@apple.com (Kent Sandvik)
- Date: 18 Sep 92 17:33:38 GMT
- Organization: Apple
-
- In article <t!#@byu.edu>, freeze@ee.byu.edu (Jim Freeze) wrote:
- Has anyone heard of Apple's new OO language, DYLAN?
- >
- > It stands for DYnamic LANguage.
- >
- > If you have heard of it, I am trying to find out if is
- > is available (i.e. can I get a compiler for it).
- > and how much and where?
-
- People are working on reference versions, I actually saw that
- DEC posted the first one, called Thomas :-). It's available
- from ftp: crl.dec.com:pub/DEC/Thomas. Works on top of various
- PD Scheme systems, not fast, but it's more for testing out the
- language concepts.
-
- Kent Sandvik
- who thinks it's time to get out a decent language to developers out there.
-
- "You should really just relax" -MST3K
- - -------------------
- Kent Sandvik (UUCP: ....!apple!ksand; INTERNET: ksand@apple.com)
- DISCLAIMER: Private activities on the Net.
-
- +++++++++++++++++++++++++++
-
- From: joswig@informatik.uni-hamburg.de (Rainer Joswig)
- Date: 23 Sep 92 16:39:38 GMT
- Organization: University of Hamburg, FRG
-
- In article <t!#@byu.edu>, freeze@ee.byu.edu (Jim Freeze) wrote:
- >
- >
- >
- > Has anyone heard of Apple's new OO language, DYLAN?
-
- You can find Information about Dylan in the
- directory /pub/dylan on the ftp server cambridge.apple.com .
- There is also the first Dylan implementation named Thomas.
- In this directory you will find an faq list about Dylan.
- There you can read about the new mailing list info-dylan.
- Sometime near there should be a newsgroup comp.lang.dylan .
-
- Rainer Joswig
- Email: joswig@informatik.uni-hamburg.de
-
- ---------------------------
-
- From: pcw@access.digex.com (Peter Wayner)
- Subject: Animated Cursors...
- Date: 17 Sep 92 22:48:34 GMT
- Organization: Express Access Online Communications, Greenbelt, MD USA
-
- Can anyone point me toward the right way
- to install an animated cursor?
-
- Thanks,
-
- Peter Wayner
- (wayner@access.digex.com)
-
- +++++++++++++++++++++++++++
-
- From: chuck@gte.com (Chuck Hoffman)
- Date: 18 Sep 92 14:07:27 GMT
- Organization: GTE Laboratories
-
- In article <1992Sep17.224834.24358@access.digex.com>, pcw@access.digex.com
- (Peter Wayner) wrote:
- >
- > Can anyone point me toward the right way
- > to install an animated cursor?
- >
-
- Create the several cursor resources you need which will make up your
- animation. Then create an 'acur' resource which is a list of the cursor
- id's. Then somewhere in your program get the 'acur' resource, then use
- SetCursor from time to time to switch from one cursor id to the next, as
- listed in the 'acur'.
-
- Someone advised recently that it could also be done through the vertical
- retrace manager, but someone else pointed out that this would hide from the
- user the effect of speeding up and slowing down which the calls from within
- the program code would reveal.
-
- Chuck Hoffman
- chuck@gte.com
- GTE Laboratories, Waltham, Massachusetts, USA
- (617) 466-2131
- =====================================
- I'm not sure why we're here, but I am sure that while we're here we're
- supposed to help each other.
- =====================================
-
- +++++++++++++++++++++++++++
-
- From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
- Date: 24 Sep 92 01:08:27 GMT
- Organization: Kalamazoo College
-
- winer@husc8.harvard.edu (Adam Winer) writes:
- >mxmora@unix.SRI.COM (Matt Mora) writes:
- >>chuck@gte.com (Chuck Hoffman) writes:
- >>>
- >>>[You can do cursor animation from inside a VBL task]
- >>
- >>The key is to have the vbl task check a counter that the program increments.
- >>The vbl would then show the true performance. And on the occasion that
- >>the program gets stuck in an endless loop, the vbl could detect that
- >>and either trigger a fail routine or jump to it.
- >
- >This strikes me as overkill: if the vbl task is going to refer back to
- >a program counter, just change the cursor from within the normal flow
- >of your program.
-
- Agreed, Adam.
-
- Additionally, Matt, I'm not sure if it would even be remotely possible
- for a VBL task to break a program out of its endless loop. You
- certainly don't want to jump straight to the fail routine; you're still
- servicing the interrupt. The only way that I can see is to find the PC
- from wherever the interrupt code hid it, check to be sure it's in your
- heap, and modify the code about to be executed by writing a "JMP fail"
- over it. Don't forget to save the original instructions somewhere so
- you can restore them, and to flush the instruction cache. :-/
-
- I'm sure there are ickier ways to crash-proof a program than using a
- periodic interrupt to save you from infinite loops, but at the moment
- I can't think of any...
- - --
- Jamie McCarthy Internet: k044477@kzoo.edu AppleLink: j.mccarthy
- "I don't think we should have to have them wandering the streets
- frightening women and people." - Pat Buchanan
-
- +++++++++++++++++++++++++++
-
- From: urlichs@smurf.sub.org (Matthias Urlichs)
- Date: 30 Sep 92 00:57:07 GMT
- Organization: University of Karlsruhe, FRG
-
- In comp.sys.mac.programmer, article <38774@unix.SRI.COM>,
- mxmora@unix.SRI.COM (Matt Mora) writes:
- >
- > The key is to have the vbl task check a counter that the program increments.
- > The vbl would then show the true performance. And on the occasion that
- > the program gets stuck in an endless loop, the vbl could detect that
- > and either trigger a fail routine or jump to it.
- >
- I don't think that jumping out of a VBL or quitting an application from
- under it would be that good an idea. Memory may be in an inconsistent state,
- the interrupt level is not zero, and the VBL queue is marked busy. Undoing
- all of this manually is a big compatibility risk.
-
- If your application hangs, it's a bug. I respectfully suggest that you debug
- your applications before shipping them to customers. ;-)
-
- - --
- Bradley's Bromide:
- If computers get too powerful, we can organize them into a
- committee -- that will do them in.
- - --
- Matthias Urlichs -- urlichs@smurf.sub.org -- urlichs@smurf.ira.uka.de /(o\
- Humboldtstrasse 7 -- 7500 Karlsruhe 1 -- Germany -- +49-721-9612521 \o)/
-
- ---------------------------
-
- From: mccabe@hatteras.cs.unc.edu (Daniel McCabe)
- Subject: Q: Stack munging in VBL tasks?
- Date: 22 Sep 92 16:48:07 GMT
-
-
- Is there a kosher way of finding out what the stack pointer was immediately
- prior to the VBL interrupt? I want to write some code which performs a
- task switch in a VBL task, but to do that, I need to know where the SP
- was prior to the VBL interrupt. I haven't found this info in either
- IM or in Tech Notes. If I missed it, any pointers are appreciated.
-
- Thanx in advance,
- danm
-
- +++++++++++++++++++++++++++
-
- From: keith@taligent.com (Keith Rollin)
- Date: 23 Sep 92 19:42:44 GMT
- Organization: Taligent
-
- In article <15544@borg.cs.unc.edu>, mccabe@hatteras.cs.unc.edu (Daniel
- McCabe) wrote:
- >
- > Is there a kosher way of finding out what the stack pointer was immediately
- > prior to the VBL interrupt? I want to write some code which performs a
- > task switch in a VBL task, but to do that, I need to know where the SP
- > was prior to the VBL interrupt. I haven't found this info in either
- > IM or in Tech Notes. If I missed it, any pointers are appreciated.
- >
-
- MPW Shell does something like this. The details are sketchy, but I think I
- have the right idea. MPW Shell installs a VBL task and then goes into a
- tight loop:
-
- TightLoop bra.s TightLoop
-
- When it gets triggered 1/60 of a second later, the VBL task then looks for
- the address of TightLoop on the stack. From that information, it determines
- what you are asking for.
-
- Why does MPW do this? I believe it's so you can press Cmd-Period to break
- out of hung tools (it also installs a VBL to look for Cmd-Period).
-
- - -----
- Keith Rollin
- Phantom Programmer
- Taligent, Inc.
-
- +++++++++++++++++++++++++++
-
- From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
- Organization: Symantec Corp.
- Date: Fri, 25 Sep 1992 15:10:16 GMT
-
- >>>>> On Wed, 23 Sep 1992 19:42:44 GMT, keith@taligent.com (Keith Rollin) said:
-
- > Why does MPW do this? I believe it's so you can press Cmd-Period to
- > break out of hung tools (it also installs a VBL to look for
- > Cmd-Period).
-
- Hmm, last time I checked MPW installs a handler in the low memory auto
- interrupt vector; kind of an odd way to check for command-period if
- you ask me. I suppose this would enable MPW to remove all VBLs
- belonging to the stopped tool, though...
-
- -phil
- - --
- Phil Shapiro Software Engineer
- Language Products Group Symantec Corporation
- Internet: phils@cs.brandeis.edu
-
- ---------------------------
-
- From: ww10+@andrew.cmu.edu (William Conrad Wojciechowski)
- Subject: WDEF's and QuickDraw globals
- Date: 30 Sep 92 09:03:43 GMT
- Organization: H&SS Dean's Office, Carnegie Mellon, Pittsburgh, PA
-
- I was wondering if anybody has a reliable solution for accessing
- QuickDraw globals in a WDEF. Right now, I am creating patterns and
- other needed globals on the fly. This is a safe method but, I would
- like to know if there is a safe way to directly access the QuickDraw
- globals.
-
- Thanks in advance.
-
- - - Will
-
- +++++++++++++++++++++++++++
-
- From: keith@taligent.com (Keith Rollin)
- Organization: Taligent
- Date: Wed, 30 Sep 1992 20:53:04 GMT
-
- In article <gemRrjq00iVgQ1o2Yn@andrew.cmu.edu>, ww10+@andrew.cmu.edu
- (William Conrad Wojciechowski) wrote:
- >
- > I was wondering if anybody has a reliable solution for accessing
- > QuickDraw globals in a WDEF. Right now, I am creating patterns and
- > other needed globals on the fly. This is a safe method but, I would
- > like to know if there is a safe way to directly access the QuickDraw
- > globals.
-
- I usually use routines like the following:
-
- typedef struct {
- char privates[76];
- long randSeed;
- BitMap screenBits;
- Cursor arrow;
- Pattern dkGray;
- Pattern ltGray;
- Pattern gray;
- Pattern black;
- Pattern white;
- GrafPtr thePort;
- } QDGlobals;
-
- long* GetA5(void) = 0x200D; // move.l A5,D0
-
- Pattern* GetWhitePattern()
- {
- long* curA5;
- curA5 = GetA5();
- return (Pattern*) (*curA5 - (sizeof(QDGlobals) - sizeof(Ptr)) +
- offsetof(QDGlobals, white));
- }
-
- - -----
- Keith Rollin
- Phantom Programmer
- Taligent, Inc.
-
- ---------------------------
-
- From: sho@bohr.physics.purdue.edu (Sho Kuwamoto)
- Subject: How do I draw icl8's?
- Date: 30 Sep 92 18:40:13 GMT
- Organization: Purdue University Physics Department
-
- IM VI gives the following useful info:
- [PlotIcon and PlotCIcon] will not draw any icons that
- are defined by the icon resources new to system
- software 7.0 -- namely, the 'ics#', 'icl4', 'ics4',
- 'icl8', and 'ics8' resources.
-
- Unfortunately, IM VI does not seem to say how one goes about
- drawing these icons. Well, how *do* I draw these types of
- icons? Also, is there an easy way for me to hilight the
- icons in the same way that the Finder does?
-
- - -Sho
- - --
- sho@physics.purdue.edu
-
- +++++++++++++++++++++++++++
-
- From: sainaney@unixg.ubc.ca (Narayan R. Sainaney)
- Organization: University of British Columbia, Vancouver, B.C., Canada
- Date: Thu, 1 Oct 1992 00:24:40 GMT
-
- In article <8352@dirac.physics.purdue.edu> sho@bohr.physics.purdue.edu (Sho Kuwamoto) writes:
- >IM VI gives the following useful info:
- > [PlotIcon and PlotCIcon] will not draw any icons that
- > are defined by the icon resources new to system
- > software 7.0 -- namely, the 'ics#', 'icl4', 'ics4',
- > 'icl8', and 'ics8' resources.
- >
- >Unfortunately, IM VI does not seem to say how one goes about
- >drawing these icons. Well, how *do* I draw these types of
- >icons? Also, is there an easy way for me to hilight the
- >icons in the same way that the Finder does?
- >
- >-Sho
- >--
- >sho@physics.purdue.edu
-
- You are in luck. I just finised working on Luanch Pad (a
- shareware app) that makes extensive use of PlotIconID which is very
- well documented in APDA tech Note 306. The routine call is:
-
- err:= PlotIconID (theRect,align,transform,theResID)
-
- where align and transform allow you to do neat stuff like center/
- left or right justify it and transfor it (launched etc etc)
-
- The interface file is at the end of the tech note and it contains
- all the values possible for align and transform (integers). The inline
- function is:
-
- function PlotIconID(theRect:Rect;align:Integer;transform:integer;
- theResID:Integer):OsErr;
- inline
- $303C,$0500,$ABC9
-
- hope this helps.
- sainaney@unixg.ubc.ca
- PS: To do a simple plot, use 0,0 for align and transform.
-
-
- ---------------------------
-
- From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
- Subject: JPartialResources.{c,h}
- Date: 24 Sep 92 23:24:23 GMT
- Organization: Kalamazoo College
-
- Following is my current working version of "Jamie's Partial Resources,"
- glue that makes the system-7 partial resource calls work under any
- system. I'm posting this here 'cause I haven't seen partial-resource
- glue anywhere else, and I thought it might be useful.
-
- Please note that this is not a final copy--jSetResourceSize() doesn't do
- anything, jWritePartialResource() has never been tested, and
- jReadPartialResource() has been extensively tested for all of forty-five
- minutes. They're working fine for me so far, though (and if there were
- anything seriously wrong, I'm sure the crashes would be spectacular).
- If and when I get it working more solidly, I'll post the code here.
- (Don't expect jSetResourceSize() though--an efficient implementation is
- far harder for that function than for the other two, and I don't need
- it yet, so it's way down low on my priority list.)
-
- Usage is simple: whenever you might call ReadPartialResource or
- WritePartialResource, call jReadPartialResource or jWritePartialResource
- instead. To get the resource handle to pass to them, SetResLoad(FALSE)
- and GetResource(type, id). (Oh, and SetResLoad(TRUE) again, of course.)
- - --
- Jamie McCarthy Internet: k044477@kzoo.edu AppleLink: j.mccarthy
- Was bringt mich nicht um...
-
-
-
- /*
- * JPartialResources.h
- *
- * Jamie's partial resource calls that work under any system.
- * (c) Copyright 1992 by Jamie R. McCarthy. All rights reserved.
- * This code can be both distributed and used freely.
- *
- */
-
-
-
- /******************************/
-
- extern Boolean partialResourceCallsAvailable;
-
- /******************************/
-
-
-
- void jReadPartialResource(Handle theResource, long offset, void *buffer, long count);
- void jWritePartialResource(Handle theResource, long offset, void *buffer, long count);
- void jSetResourceSize(Handle theResource, long size);
-
-
-
-
-
- /*
- * JPartialResources.c
- *
- * Jamie's partial resource calls that work under any system.
- * (c) Copyright 1992 by Jamie R. McCarthy. All rights reserved.
- * This code can be both distributed and used freely.
- * Internet: k044477@kzoo.edu AppleLink: j.mccarthy
- * Telephone: 800-421-4157 or US 616-665-7075 (9:00-5:00 Eastern time)
- * I'm releasing this code with the hope that someone will get something
- * out of it. Feedback of any sort, even just letting me know that you're
- * using it, is greatly appreciated!
- *
- *
- * "Be aware that having a copy of a resource in memory when you are using
- * the partial resource routines may cause problems. If you have modified
- * the copy in memory and then access the resource on disk using either
- * the ReadPartialResource or WritePartialResource procedure, you will
- * lose changes made to the copy in memory." - IM VI, 13-21
- *
- * By "copy in memory," this refers to having the entire resource loaded in.
- * What it's saying is that ReadPartialResource and WritePartialResource
- * consider themselves free to purge (and maybe reload) the resource
- * handle. Incidentally, my routines don't do that--they read directly from
- * disk--so if you're under system 6, your copy of the resource is safe.
- * (Memory may be moved, however, so if the resource is purgeable, it may
- * be purged.)
- *
- *
- * "...there's really no reason to access resources directly." - IM IV-16.
- *
- * Yeah right.
- *
- */
-
-
-
- /******************************/
-
- #include "JPartialResources.h"
-
- /******************************/
-
- #include <GestaltEqu.h>
-
- /******************************/
-
- #define kUninitializedFlag (42)
- Boolean partialResourceCallsAreAvailable = kUninitializedFlag;
-
- void determineWhetherPRCallsAreAvailable(void);
-
- /******************************/
-
- typedef struct {
- unsigned long offsetToRsrcData;
- unsigned long offsetToRsrcMap;
- unsigned long lengthOfRsrcData;
- unsigned long lengthOfRsrcMap;
- } rsrcForkHeader;
-
- typedef struct {
- short rsrcID;
- short offsetToRsrcName;
- unsigned long rsrcAttrs : 8;
- unsigned long offsetToRsrcData : 24;
- Handle rsrcHndl;
- } rsrcReference;
-
- struct rsrcMap;
- typedef struct rsrcMap rsrcMap, *rsrcMapPtr, **rsrcMapHndl;
- struct rsrcMap {
- rsrcForkHeader copyOfRsrcForkHeader;
- rsrcMapHndl nextRsrcMapHndl;
- short fileRefNum;
- short fileAttrs;
- unsigned short offsetToTypeList;
- unsigned short offsetToNameList;
- } ;
-
- /******************************/
-
- /*
- * Lower-level internal functions.
- */
-
- /*
- * Just as _HomeResFile returns the refNum of a resource's file,
- * so does getHomeRsrcMap() return a pointer to the resource
- * file's map. Warning--any calls that may move memory,
- * including system memory, invalidate the pointer!
- */
- rsrcMapPtr getHomeRsrcMap(Handle theResource);
-
- /*
- * This uses _RsrcMapEntry and getHomeRsrcMap() to find the
- * offset from the beginning of a resource fork to the start of
- * a resource's reference.
- */
- long getRsrcRefOffsetIntoFile(Handle theResource);
-
- /******************************/
-
- /*
- * Higher-level internal functions.
- */
-
- /*
- * This uses getRsrcRefOffsetIntoFile() and FSRead() to find
- * the offset from the beginning of a resource fork to the start
- * of a resource's data. The offset points to the data itself,
- * which is just past the longword that tells its size. If you
- * happen to want the size too, use _SizeResource.
- */
- long getRsrcDataOffsetIntoFile(Handle theResource);
-
- long getRsrcFileMark(Handle theResource);
- void setRsrcFileMark(Handle theResource, long newMark);
-
- /******************************/
-
-
-
- void jReadPartialResource(Handle theResource, long offset, void *buffer, long count)
- {
- if (partialResourceCallsAreAvailable == kUninitializedFlag) {
- determineWhetherPRCallsAreAvailable();
- }
-
- if (partialResourceCallsAreAvailable) {
- ReadPartialResource(theResource, offset, buffer, count);
- } else {
-
- long theRsrcDataOffset;
- long theRsrcDataLength;
- OSErr theErr;
- long oldMark;
-
- oldMark = getRsrcFileMark(theResource);
- theRsrcDataOffset = getRsrcDataOffsetIntoFile(theResource);
- if (theRsrcDataOffset < 0) return ;
- setRsrcFileMark(theResource, theRsrcDataOffset + offset);
- theErr = FSRead( HomeResFile(theResource), &count, buffer );
- setRsrcFileMark(theResource, oldMark);
-
- }
- }
-
-
-
- void jWritePartialResource(Handle theResource, long offset, void *buffer, long count)
- {
- if (partialResourceCallsAreAvailable == kUninitializedFlag) {
- determineWhetherPRCallsAreAvailable();
- }
-
- /*
- * Disallow writing past the end of the resource;
- * try to increase its size if possible.
- */
- if (SizeResource(theResource) < offset+count) {
- jSetResourceSize(theResource, offset+count);
- }
-
- /*
- * Check to be sure the size was successfully increased
- * before continuing.
- */
- if (SizeResource(theResource) < offset+count) {
- return ;
- }
-
- if (partialResourceCallsAreAvailable) {
- WritePartialResource(theResource, offset, buffer, count);
- } else {
-
- long theRsrcDataOffset;
- OSErr theErr;
- long oldMark;
-
- oldMark = getRsrcFileMark(theResource);
- theRsrcDataOffset = getRsrcDataOffsetIntoFile(theResource);
- if (theRsrcDataOffset < 0) return;
- setRsrcFileMark(theResource, theRsrcDataOffset + offset);
- theErr = FSWrite( HomeResFile(theResource), &count, buffer );
- setRsrcFileMark(theResource, oldMark);
-
- }
- }
-
-
-
- void jSetResourceSize(Handle theResource, long size)
- {
- if (partialResourceCallsAreAvailable == kUninitializedFlag) {
- determineWhetherPRCallsAreAvailable();
- }
-
- if (partialResourceCallsAreAvailable) {
- SetResourceSize(theResource, size);
- } else {
-
- Debugger();
-
- }
- }
-
-
-
- void determineWhetherPRCallsAreAvailable(void)
- {
- if (partialResourceCallsAreAvailable == kUninitializedFlag) {
- OSErr theOSErr;
- long theResponse;
- partialResourceCallsAreAvailable = FALSE;
- #ifdef appleHadActuallyImplementedTheResourceMgrAttrSelectorInSystem7_0_x
- theOSErr = Gestalt(gestaltResourceMgrAttr, &theResponse);
- if (theOSErr == noErr) {
- if ( (theResponse & 1L<<gestaltPartialRsrcs) != 0 ) {
- partialResourceCallsAreAvailable = TRUE;
- }
- }
- #else
- theOSErr = Gestalt(gestaltSystemVersion, &theResponse);
- if (theOSErr == noErr) {
- if ( (theResponse & 0x0000FFFF) >= 0x0700 ) {
- partialResourceCallsAreAvailable = TRUE;
- }
- }
- #endif
- }
- }
-
-
-
- /******************************/
-
-
-
- rsrcMapPtr getHomeRsrcMap(Handle theResource)
- {
- rsrcMapHndl cMapHndl;
- short theRefNum;
-
- theRefNum = HomeResFile(theResource);
- cMapHndl = (rsrcMapHndl) TopMapHndl;
-
- while ( (**cMapHndl).fileRefNum != theRefNum ) {
- cMapHndl = (**cMapHndl).nextRsrcMapHndl;
- if (cMapHndl == NULL) return NULL;
- }
-
- return *cMapHndl;
- }
-
-
-
- long getRsrcRefOffsetIntoFile(Handle theResource)
- {
- long offsetToRsrcRefFromRsrcMap;
- long offsetToRsrcMapFromStartOfFile;
-
- rsrcMapPtr theRsrcMapPtr;
-
- ASSERT(theResource != NULL);
-
- offsetToRsrcRefFromRsrcMap = RsrcMapEntry(theResource);
- if (offsetToRsrcRefFromRsrcMap == 0) {
- /* ResError contains the error. */
- return -1;
- }
-
- theRsrcMapPtr = getHomeRsrcMap(theResource);
- offsetToRsrcMapFromStartOfFile = theRsrcMapPtr->copyOfRsrcForkHeader.offsetToRsrcMap;
-
- return offsetToRsrcMapFromStartOfFile + offsetToRsrcRefFromRsrcMap;
- }
-
-
-
- long getRsrcDataOffsetIntoFile(Handle theResource)
- {
- rsrcReference theRsrcRef;
- long theOffsetToRsrcRef;
- long theOffsetToRsrcData;
- long oldMark;
- OSErr theErr;
- long nBytesToRead;
-
- theOffsetToRsrcRef = getRsrcRefOffsetIntoFile(theResource);
-
- oldMark = getRsrcFileMark(theResource);
- setRsrcFileMark(theResource, theOffsetToRsrcRef);
- nBytesToRead = sizeof(rsrcReference);
- theErr = FSRead( HomeResFile(theResource), &nBytesToRead, &theRsrcRef);
- setRsrcFileMark(theResource, oldMark);
-
- if (theErr != noErr || nBytesToRead < sizeof(rsrcReference)) {
- return -1;
- }
-
- theOffsetToRsrcData = theRsrcRef.offsetToRsrcData
- + 0x0100 // add in the length of the resource header
- + 4; // skip over the longword that tells the resource's length
- return theOffsetToRsrcData;
- }
-
-
-
- long getRsrcFileMark(Handle theResource)
- {
- OSErr theErr;
- long theMark;
- ASSERT(theResource != NULL);
- theErr = GetFPos( HomeResFile(theResource), &theMark );
- if (theErr != noErr) theMark = -1;
- return theMark;
- }
-
-
-
- void setRsrcFileMark(Handle theResource, long newMark)
- {
- ASSERT(theResource != NULL);
- /* theOSErr = */ SetFPos( HomeResFile(theResource), fsFromStart, newMark );
- }
-
- +++++++++++++++++++++++++++
-
- From: mgleason@cse.unl.edu (Mike Gleason)
- Date: Fri, 25 Sep 1992 21:15:32 GMT
- Organization: NCEMRSoft
-
- k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
-
- >Following is my current working version of "Jamie's Partial Resources,"
- >glue that makes the system-7 partial resource calls work under any
- >system. I'm posting this here 'cause I haven't seen partial-resource
- >glue anywhere else, and I thought it might be useful.
-
- > [code omitted]
-
- This reminds me of a catch-22 when writing apps that run under 7.0 and 6.x.
- You end up using the archaic 6.x routines because 6.x doesn't have the useful
- 7.0 stuff, and/or writing your own version of the 7.0 stuff for the 6.x users.
- Prime example: the FSSpec calls in the 7.0 File Manager. Wouldn'tcha just
- love to use these? Unless you write your own glue to use FSSpecs you have
- to settle with using FSSpecs as variables, then passing fs.name, fs.vRefNum,
- and fs.parID to HOpen() instead of FSpOpenDF().
-
- I nominate that the FSSpec calls be added to a new System version 6.1.
- There are probably other bits (like partial resources, even though they're
- not used often) that could be added to a 6.1 that wouldn't require the rest
- of the 7.0 OS.
-
- - --
- ______________________________________________________________________________
- mike gleason mgleason@cse.unl.edu NCEMRSoft, baby!
-
- +++++++++++++++++++++++++++
-
- From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
- Date: 25 Sep 92 22:59:52 GMT
- Organization: Kalamazoo College
-
- mgleason@cse.unl.edu (Mike Gleason) writes:
- >k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
- >
- >This reminds me of a catch-22 when writing apps that run under 7.0 and 6.x.
- >You end up using the archaic 6.x routines because 6.x doesn't have the useful
- >7.0 stuff, and/or writing your own version of the 7.0 stuff for the 6.x users.
- >
- >I nominate that the FSSpec calls be added to a new System version 6.1.
- >There are probably other bits (like partial resources, even though they're
- >not used often) that could be added to a 6.1 that wouldn't require the rest
- >of the 7.0 OS.
-
- ...and then how many users would upgrade to 6.1? We'd still end up
- having to write the dual-system code for the next n years, until a
- sufficiently small number of 6.0 users remained.
-
- Ideally, Apple would release small code libraries (object code maybe?)
- that would do the Right Thing for things like the new FSSpec calls under
- both 7 and 6. It'd save developers a lot of hassle, and would get
- studly products to market quicker...of course, if they'd intended to do
- that, they'd have done it two years ago...
- - --
- Jamie McCarthy Internet: k044477@kzoo.edu AppleLink: j.mccarthy
- I'm your only friend, I'm not your only friend, but I'm a little glowing
- friend, but really I'm not actually your friend, but I am...
-
- +++++++++++++++++++++++++++
-
- From: sdorner@qualcomm.com (Steven Dorner)
- Date: 27 Sep 92 16:14:12 GMT
- Organization: Qualcomm, Inc
-
- k044477@hobbes.kzoo.edu (Jamie R. McCarthy) wrote:
- > ...and then how many users would upgrade to 6.1? We'd still end up
- > having to write the dual-system code for the next n years, until a
- > sufficiently small number of 6.0 users remained.
-
- System 7 will be two years old this coming spring. 1M SIMM's are $25.
- Enough is enough; I'm making one more system 6 compatible release, and then
- I'm simply going to forget that System 6 ever existed.
-
- +++++++++++++++++++++++++++
-
- From: grobbins@Apple.COM (Grobbins)
- Date: 27 Sep 92 22:53:38 GMT
- Organization: Apple Computer Inc., Cupertino, CA
-
- In article <1992Sep25.225952.24833@hobbes.kzoo.edu> k044477@hobbes.kzoo.edu (Jamie R. McCarthy) writes:
- >mgleason@cse.unl.edu (Mike Gleason) writes:
- >>I nominate that the FSSpec calls be added to a new System version 6.1.
- >>There are probably other bits (like partial resources, even though they're
- >>not used often) that could be added to a 6.1 that wouldn't require the rest
- >>of the 7.0 OS.
- >Ideally, Apple would release small code libraries (object code maybe?)
- >that would do the Right Thing for things like the new FSSpec calls under
- >both 7 and 6.
-
- The current interfaces do help a bit; in particular, Gestalt and
- FindFolder can be used without regard to the system being run
- because of the glue which is automatically supplied (at least
- by the MPW and Think C and Pascal compilers.)
-
- If your main desire is for FSSpecs, it's easy to write wrapper
- functions. Alternatively, most FSp---- and Alias Manager calls
- are available under System 6.0.7 if QuickTime is installed, so that
- is one way to modernize old system versions.
-
- Grobbins grobbins@apple.com
-
- Usual disclaimers apply.
-
- +++++++++++++++++++++++++++
-
- From: peirce@outpost.SF-Bay.org (Michael Peirce)
- Date: 29 Sep 92 00:06:43 GMT
- Organization: Peirce Software
-
-
- In article <sdorner-270992111026@dorner.slip.uiuc.edu> (comp.sys.mac.programmer), sdorner@qualcomm.com (Steven Dorner) writes:
- > k044477@hobbes.kzoo.edu (Jamie R. McCarthy) wrote:
- > > ...and then how many users would upgrade to 6.1? We'd still end up
- > > having to write the dual-system code for the next n years, until a
- > > sufficiently small number of 6.0 users remained.
- >
- > System 7 will be two years old this coming spring. 1M SIMM's are $25.
- > Enough is enough; I'm making one more system 6 compatible release, and then
- > I'm simply going to forget that System 6 ever existed.
-
- My product Smoothie doesn't support System 6. It came out after System
- 7 had been around a while and it takes advantage of a number of System 7
- features.
-
- I've yet to have anyone complain about not supporting System 6...
- (no doubt I'll get a complain about 15 minutes after I post this,
- but so far so good!)
-
- - -- Michael Peirce -- peirce@outpost.SF-Bay.org
- - -- Peirce Software -- Suite 301, 719 Hibiscus Place
- - -- -- San Jose, California USA 95117
- - -- Makers of... -- voice: (408) 244-6554 fax: (408) 244-6882
- - -- SMOOTHIE -- AppleLink: peirce & America Online: AFC Peirce
-
- ---------------------------
-
- End of C.S.M.P. Digest
- **********************
-